class Solution {
    public int[] constructArr(int[] a) {
        int len = a.length;
        int[] b = new int[len];
        //记录i前面的乘积,初始位置前面的乘积为0
        int sum = 1;
        int i = 0;
        for(i = 0;i<len;i++) {
            b[i] = sum;
            sum*=a[i];
        }
        //记录i后面的乘积
        sum = 1;
        for(i = len-1;i>=0;i--) {
            b[i]*=sum;
            sum*=a[i];
        }
        return b;
    }
}